﻿/*
 * This software is the confidential and proprietary
 * information of NetBay
 * Such confidential information should not be disclosed
 * NetBay copyright(c) 2010
 */

#region Using
using System;
using System.ServiceModel.DomainServices.Server;
using NetBay.Core.BusinessEntities;
using System.Web;
using System.ServiceModel.DomainServices.Hosting;
using System.ServiceModel;
#endregion

namespace Rio.Applications.Web.Services.BusinessEntities
{
    [ServiceBehavior(MaxItemsInObjectGraph = 2147483647)]
    [EnableClientAccess(RequiresSecureEndpoint = false)]
    public partial class ToolsDS : DomainService
    {
        public static void CleanMemory()
        {
            GC.Collect();
        }

        /// <summary>
        /// This service is used to log a client exception
        /// </summary>
        /// <param name="p_sModule">The P_S module.</param>
        /// <param name="p_sExceptionMessage">The P_S exception message.</param>
        [Invoke(HasSideEffects = true)]
        public void LogClientError(String p_sModule, String p_sExceptionMessage)
        {
            try
            {
                var l_oUserInSession = (User)HttpContext.Current.Session[ParameterSession.CurrentUser.szGetDescription()];
                if (l_oUserInSession != null)
                {
                    NetBay.Core.Log.LogManager.Instance().LogError("CLIENT ERROR:" + l_oUserInSession.FullName + " - MODULE:" + p_sModule + " - EXCEPTION:" + p_sExceptionMessage);
                }
                else
                {
                    NetBay.Core.Log.LogManager.Instance().LogError("CLIENT ERROR: Not authentified - MODULE: " + p_sModule + " - EXCEPTION:" + p_sExceptionMessage);
                }
            }
            catch (Exception ex )
            {
                NetBay.Core.Log.LogManager.Instance().LogError("LogClientError error " + ex.ToString());
            }
        }
    }
}